<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>

<?php
	$url = $this->baseurl.'/images/com_retailshop/';	
	$caregory = '';
	if(isset($this->categoryMenus) && isset($_GET['shop_id'])){
	for($i = 0 ; $i < count($this->categoryMenus); $i++){
		if($i!=3)
			$caregory .= '<li><a href="index.php?option=com_retailshop&view=myshop&task=products&shop_id='.$_GET['shop_id'] .'&idp='.$this->categoryMenus[$i]->id.'">'.$this->categoryMenus[$i]->name.'</a></li>';
		else{
			$caregory .= '<li class="last"><a href="index.php?option=com_retailshop&view=myshop&task=products&shop_id='.$_GET['shop_id'] .'&idp='.$this->categoryMenus[$i]->id.'">'.$this->categoryMenus[$i]->name.'</a></li>';
			break;
		}
	}}
?>
<?php 
	$url = $this->baseurl.'/images/com_retailshop/';			
?>
<div id="main">
    	<div class="wrapper wmain">
        	<div id="main-premium">
                <div class="main-content">
                	<h4>Detail of Product</h4>
					<div id="product-block" class="blockwhite">
						<?php if($this->product != null) { ?>
						<div class="detail-product">
							<img src="<?php echo $url.$this->product->image_url; ?>" width="170" height="170" />
							<div class="info-product">
								<div class="detail-product-left">
									
									<div class="name-product">
										<h3><?php echo $this->product->title; ?></h3>
									</div>
									<?php if($this->product->deal > 0) { ?>
									<div id="clock_<?php echo $this->product->id; ?>" class="clock" style="<?php echo $this->product->timetime; ?>" >
										  <p>
											<span id="hours_<?php echo $this->product->id; ?>"></span>
											Hours
										  </p>
										  <div class="space">:</div>
										  <p>
											<span id="minutes_<?php echo $this->product->id; ?>"></span>
											Minutes
										  </p>
										  <div class="space">:</div>
										  <p>
											<span id="seconds_<?php echo $this->product->id; ?>"></span>
											Seconds
										  </p>
									</div>
									<?php } ?>
									<div class="short-descripsion">
										<p><?php echo $this->product->short_description; ?></p>
									</div>
									
								</div>
								<div class="detail-product-right">
                                	<?php if($this->product->deal > 0): ?>
									<div class="price-box">
										 <p class="price-new">
											 
											 <span id="product-price" class="price"><?php echo ($this->product->price - $this->product->promotion*$this->product->price/100); ?> $</span>
										 </p>
										 <p class="price-old">
											 
											 <span id="product-price" class="price"><s><?php echo $this->product->price; ?> $</s></span>
										 </p>
									</div>
                                    <?php else: ?>
                                    	<div class="price-box">
										 <p class="price-new">
											 
											 <span id="product-price" class="price"><?php echo number_format($this->product->price,2); ?> $</span>
										 </p>
									</div>
                                    <?php endif; ?>
								</div>
								<div class="call_back">
									<span>You may also request for <a href="#" class="call-order">Call Back to order</a></span>
								</div>
								<div id="contactbox">
									<div id="cb-title">I Want To Order</div>
									<div id="cb-content">
										<form name="contact_frm" method="post" action="">
												<div class="element">
													<label>Name:<span class="requierd_field"> *</span></label>
													<input name="txtname" type="text" value="">
												</div>
												<div class="element">
													<label>Email ID:<span class="requierd_field"> *</span></label>
													<input name="txtemail" type="text" value="">
												</div>
												<div class="element">
													<label>Mobile:<span class="requierd_field"> *</span></label>
													<input name="txtmobile" type="text" maxlength="10">
												</div>
												<div class="element">
													<label>Product Name:<span class="requierd_field"> *</span></label>
													<input name="txtproductname" type="text" maxlength="150" class="proname" value="<?php  echo $this->product->title; ?>" >
												</div>												
												<input type="submit" name="btncallme" class="submit_button_1" value="Call Me Back">
											</form>
										</div>
								</div>
							</div>
						</div>
			
						<div class="similar-product">
							<h3>Similar Product</h3>
							<ul>
								<?php if($this->productrelate == null){?>
									NO RELATE PRODUCT
								<?php }else { ?>								
								<?php foreach($this->productrelate as $relate){ ?>
								<li>
									<a href="index.php?option=com_retailshop&view=myshop&task=productdetail&shop_id=<?php echo $this->shop->id; ?>&id=<?php echo $relate->id; ?>"><center><img src="<?php echo $url.$relate->image_url; ?>" width="70" height="70" alt="product" /></center></a>
									<h2 class="product-name">
										<a href="index.php?option=com_retailshop&view=myshop&task=productdetail&shop_id=<?php echo $shop->id; ?>&id=<?php echo $relate->id; ?>"><?php echo $relate->name?></a>
									</h2>
									<div class="price-box">
										<p class="price-new">
											<span class="price-label">Price:</span>
											<span id="product-price" class="price"><?php echo ($relate->price - $relate->promotion*$relate->price/100); ?> $</span>
										 </p>
									</div>
								</li>
								<?php } } ?>
							</ul>
						</div>
						<?php } ?>
						
						<div id="commentproduct" style="clear: both; " class="comment">
							<h3>Comment</h3>
							<ul>
							<?php if(count($this->listcomment)>0){ ?>
							<?php foreach($this->listcomment as $commnet) { ?>
								<li>									
									
										<p class="title"><?php echo $commnet->title; ?></p> 
										<p class="says"><span class="name"><?php echo $commnet->name; ?> </span>says:</p>
									<div class="result-commmet">	
										<p><?php echo $commnet->content; ?></p>
									</div>
								</li>
							<?php } } ?>
							</ul>							
						</div>
						
						<div class="comment">
							<div class="form-add">   
								<form action="#" name="commnet" method="post" id="adminForm">
									<h3>Your comment</h3>
									<div class="form">
										<div class="element">
											<label>Title</label>
											<input type="text" name="title-comment" value="" id="titlecomment"/>
										</div>
										<div class="element">
											<label>Email</label>
											<input type="text" name="email-comment" value="" id="emailcomment"/>
										</div>
										<div class="element">
											<label>Name</label>
											<input type="text" name="name-comment" value="" id="namecomment"/>
										</div>
										<div class="element">
											<label>Content</label>
											<textarea class="required-entry" rows="6" cols="50" id="review_field" name="detail"></textarea>
										</div>
									</div>      
									<div class="bt-review">
										<div class="buttons-set">
											<button id="btncommet" type="button">Send</button>
										</div>
									</div>    
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
            <div id="main-search">
          <?php
	// No direct access to this file
	defined('_JEXEC') or die('Restricted access');
	$url = $this->baseurl.'/images/com_retailshop/';
?>
<div id="detail-shop" class="block">
            	<?php echo $this->loadTemplate('header');?>
            </div>
			<div id="category-block" class="block">
              	<h4>Category</h4>
                <div class="block-content">
                	<ul>
						<?php if($this->catagorys == null){ ?>
						<li class="no-category">NO CATEGORY</li>
						<?php }else{ ?>
						<?php foreach($this->catagorys as $c){ ?>
						<li><a a href="index.php?option=com_retailshop&view=myshop&task=products&shop_id=<?php echo $this->shop->id ?>&idp=<?php echo $c->id; ?>"><?php echo $c->name; ?></a></li>
						<?php }} ?>
                    </ul>
                </div>
              </div>
            
            <div id="list-events" class="block">
            	<h4>List Events</h4>
                <ul class="carou">
					<?php if ($this->events == null){ ?>
					<li class="no-event">NO EVENT</li>
					<?php }else { ?>
					<?php foreach($this->events as $e){ ?>
                	<li>
						<a href="index.php?option=com_retailshop&view=myshop&task=eventdetail&idp=<?php echo $e->id; ?>&shop_id=<?php echo $e->shop_id; ?>"><p><?php echo $e->title; ?></p></a>
						<span class="from">From: </span>
						<span class="start-date"><?php echo substr($e->start_date,0,10)?></span>
						- <span class="to">To: </span>
						<span class="end-date"><?php echo substr($e->end_date,0,10); ?></span>
					
					</li>                    
					<?php } } ?>
                </ul>
            </div> 
          </div>
        
       </div>
    </div>

	<script type="text/javascript" charset="utf-8">	
    $(function() {
		$('#btncommet').click(function(){			
		var titlecomment = $('#titlecomment').val();
		var emailcomment = $('#emailcomment').val();
		var namecomment = $('#namecomment').val();
		var review_field = $('#review_field').val();
		
		var comment = '<li><div class="result-commmet"><p>'+ titlecomment +'</p> <span>Name: '+ namecomment +' </span> - <span>email: '+ emailcomment +'</span><p>'+ review_field +'</p></div></li>';
		$('#commentproduct ul li').after(comment);
		$.ajax({	
				url:"index.php?option=com_retailshop&view=myshop&task=addcomment&value=<?php echo $_GET['id']; ?>",
				data:{titlecomment:titlecomment,emailcomment:emailcomment,namecomment:namecomment,review_field:review_field},
				type: "POST",
				dataType: "html",
				success:function(data) {										
					$('#titlecomment').val('');
					$('#emailcomment').val('');
					$('#namecomment').val('');
					$('#review_field').val('');
					location.reload();
				},
				error: function (){
					alert('loi');
				}
			});			
	});
      $(document).ready(function(){
			$(".clock").each(function(){
				var id = $(this).attr("id");
				var dateAviable = $(this).attr("style");
				dateAviable = Number(dateAviable).valueOf();
				LoadClock(id,dateAviable);
			});	
      });
		function LoadClock(id,dateAviable)
		{
			var arr = id.split("_");
			var deadl_id = arr[1];
			 var currentDate = new Date();
			  finished = false;	
			$("div#" + id).countdown(dateAviable + currentDate.valueOf(),function(event){
				 $this = $(this);
				switch(event.type) {
  				case "seconds":
  				case "minutes":
  				case "hours":
  				case "days":
  				case "weeks":
  				case "daysLeft":
  				  $this.find('span#'+event.type + "_" + deadl_id).html(event.value);
  				  if(finished) {
  				    $this.fadeTo(0, 1);
  				    finished = false;
  				  }
  					break;
  				case "finished":
				$this.fadeTo('slow', .5);
				finished = true;
  					break;
				}
			});
		}
  		
  		$('select#exampleDate').change(function() {
  		  try {
    		  var $this = $(this),
    		      value;
  		    currentDate = new Date();
    		  switch($this.attr('value')) {
    		    case "other":
    		      value = prompt('Set the date to countdown:\nThe hh:mm:ss parameters are opitionals', 'YYYY/MM/DD hh:mm:ss');
    		      break;
    		    case "daysFromNow":
    		      value = prompt('How many days from now?', '');
    		      value = new Number(value) * 24 * 60 * 60 * 1000 + currentDate.valueOf();
    		      break;
    		    case "minutesFromNow":
    		      value = prompt('How many minutes from now?', '');
    		      value = new Number(value) * 60 * 1000 + currentDate.valueOf();
    		      break;
    		    default:
    		      value = availiableExamples[$this.attr('value')] + currentDate.valueOf();
    		  }
    		  $('div#clock').countdown(value, callback);
    		  $this.find('option:first').attr('selected', true);
    		} catch(e) { alert(e); }
  		});
  	});
  </script>
    <script type="text/javascript">
    $(window).load(function() {
		$('#sub-nav ul').html('<?php echo $caregory; ?>');
    });
	$('.call-order').click(function (e) {
				$('#contactbox').modal({minWidth:470, minHeight:210});
				return false;
			});
<?php if(isset($_POST['btncallme'])){ ?>			
alert('Thank you for showing interest in retailshop.info. Our representative will get back to you soon. Happy to serve you :-)');
<? } ?>
    </script>